home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Bill's Win32Asm Page / splitter1.txt < prev    next >
Text File  |  2000-05-25  |  2KB  |  68 lines

  1. Multiple-Pane Splitter Bar
  2. By Bill T.
  3. August 12, 1999
  4.  
  5. -----------------------------------------------------------------------------
  6.  
  7. This bit of code will show you a very easy way to implement a vertical splitter
  8. (as in explorer).  Using this method, the parent window handles all of the 
  9. resizing.  The child windows are positioned so that only the space between them 
  10. shows through.  This space (which is part of the parent) is the splitter bar.  
  11.  
  12. When you create the main window's class, you may want to change the hCursor 
  13. member to IDC_SIZEWE or something similar so it changes when the mouse is put 
  14. over it.  The iSeparatorPos variable holds the current x-position of the splitter
  15. bar. 
  16.  
  17. Of course, this is not the only (or best) way to implement these splitter bars. 
  18. For instance, this method may have difficulty with more than 2 panes, or when 
  19. there are horiontal and vertical splitters... 
  20.  
  21. Note this is only a sample of how it might be implememnted, and is not an
  22. actual, working implementation.
  23.  
  24.  
  25. ; These go into the MainWindow Procedure: 
  26.      mov    eax, uMsg 
  27.      cmp    eax, WM_MOUSEMOVE 
  28.      je     wmmousemove 
  29.      cmp    eax,WM_LBUTTONDOWN 
  30.      je     wmlbuttondown 
  31.      cmp    eax,WM_LBUTTONUP 
  32.      je     wmlbuttonup  
  33.      ... 
  34.  
  35. ; mouse is moved 
  36. wmmousemove: 
  37.     test   wParam, MK_LBUTTON 
  38.     jz     return 
  39.     ; left button is down, move the splitter 
  40.     mov    eax, lParam 
  41.     and    eax, 0000FFFFh ;LOWORD(lParam = xpos) 
  42.     mov    iSeparatorPos, eax  
  43.     ; get the dimensions of the application window 
  44.     invoke GetWindowRect, hWndMainApp, addr rect 
  45.     ; re-size the left pane 
  46.     mov    eax, iSeparatorPos 
  47.     dec    eax 
  48.     invoke MoveWindow, hWndLeftPane, 0, 0, eax, rect.bottom, TRUE 
  49.     ; now re-size the right pane 
  50.     mov    eax, iSeparatorPos 
  51.     inc    eax 
  52.     invoke MoveWindow, hWndLRightPane, eax, 0, rect.right, rect.bottom, TRUE 
  53.     jmp    return 
  54.  
  55. ; Left mouse button is pressed 
  56. wmlbuttondown: 
  57.     invoke SetCapture, hWnd  
  58.     jmp    return 
  59.  
  60. ; Left mouse button is released  
  61. wmlbuttonup: 
  62.     invoke ReleaseCapture 
  63.     jmp    return
  64.  
  65. -----------------------------------------------------------------------------
  66.  
  67. Copyright (C) 1999
  68. Bill T.  (billasm@usa.net)